
/*
 * 随机数
 * 随机生成指定区间的整数或小数(整数返回Number小数返回String)
 * @param {Number} maxNum - 随机数的最大值
 * @param {Number} minNum - 随机数的最小值
 * @param {Number} decimalNum - 如果是小数则指定的小数位数
 * @return String/Number
 */

function random(maxNum, minNum, decimalNum) {
	var max = 0, min = 0;
	minNum <= maxNum ? (min = minNum, max = maxNum) : (min = maxNum, max = minNum);
	switch (arguments.length) {
		case 1:
			return Math.floor(Math.random() * (max + 1));
			break;
		case 2:
			return Math.floor(Math.random() * (max - min + 1) + min);
			break;
		case 3:
			return (Math.random() * (max - min) + min).toFixed(decimalNum);
			break;
		default:
			return Math.random();
			break;
	}
}

export default random;